import re

import pandas as pd

data = pd.read_csv('data/data.csv')
# 设置显示选项
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)


def extract_minimum_salary(salary_str):
    # 使用正则表达式查找薪资数字
    match = re.search(r'(\d+)-(\d+)K', salary_str)
    if match:
        # 返回最低薪资
        return int(match.group(1)) * 1000  # 将 'K' 转换为千
    else:
        return None


data['jobId'] = data['id']
data['minimumSalary'] = data['salary'].apply(extract_minimum_salary)

# 查看结果
print(data[['jobId', 'salary', 'minimumSalary']])
# 将结果保存到CSV文件
data[['jobId', 'salary', 'minimumSalary']].to_csv('data/salary.csv', index=False)
